package il.ac.braude.sona.constants;

import java.io.Serializable;

/**
 * Class with message attributes. Messages to an from  server.
 * @author Ofek Ron
 * @author Avihay Avitan
 * @author Nitzan Inbar
 * @author Sasha Rozenthal  *
 */
@SuppressWarnings("serial")
public class Mssg implements Serializable {	
	private static long idProvider;
	private long id;
	private String type;
	private Object mssg;
	/**
	 * Class constructor
	 * @param id message id
	 * @param type type of message
	 * @param mssg the message itself
	 */
	public Mssg(Long id, String type, Object mssg) {
		this.id=id;
		this.mssg=mssg;
		this.type=type;
	}
	/**
	 * Class constructor
	 * @param type type of message
	 */
	public Mssg(String type) {
		id=idProvider++;
		this.type=type;
	}
	/**
	 * Class constructor
	 * @param type type of message
	 * @param mssg the message itself
	 */
	public Mssg(String type, Object mssg) {
		id=idProvider++;
		this.type=type;
		this.mssg=mssg;
	}
	public Mssg(int i) {
		id=i;
	}
	/**
	 * Id getter
	 * @return id
	 */
	public Long getID() {
		return id;
	}
	/**
	 * id setter
	 * @param id
	 */
	public void setID(long id) {
		this.id=id;
	}
	/**
	 * message setter
	 * @param mssg
	 */
	public void setMessege(Object mssg) {
		this.mssg=mssg;
	}
	/**
	 * message getter
	 * @return message
	 */
	public Object getMessege() {
		return mssg;
		
	}
	/**
	 * Method that determines the message type.
	 * @param ofType type to check
	 * @return true if the message type is the one inputed
	 */
	public boolean is(String ofType) {
		if (ofType.startsWith(type)) return true;
		return false;
	}
	/**
	 * Type setter.
	 * @param type
	 */
	public void setType(String type) {
		this.type=type;
	}
	/**
	 * Type getter.
	 * @return type
	 */
	public String getType() {
		return type;
	}
}
